# -*- coding: utf-8 -*-
"""
Flask应用工厂
"""
from flask import Flask
from apps.setting import config
from apps.common.script import init_script
from apps.extensions import init_exts
from apps.modules import init_bps

def create_app(config_name='default'):
    """创建Flask应用实例"""
    app = Flask(__name__)

    # 加载配置
    app.config.from_object(config[config_name])

    # 注册flask组件
    init_exts(app)

    # 注册蓝图
    init_bps(app)

    # 注册命令
    init_script(app)
    
    return app